package ch12.test;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;

public class CopyClass {

	public static void main(String[] args) {
		try {
			FileReader inOne = new FileReader("d:/io/copysrc.doc");
			BufferedReader inTwo = new BufferedReader(inOne);
			FileWriter tofile = new FileWriter("d:/io/copydes.doc");
			BufferedWriter out = new BufferedWriter(tofile);
			String s = null;
			while ((s = inTwo.readLine()) != null) {
				out.write(s);
				out.newLine();
			}
			
			out.flush();
			out.close();
			tofile.close();
			inOne = new FileReader("d:/io/copydes.doc");
			inTwo = new BufferedReader(inOne);
			while ((s = inTwo.readLine()) != null) {
				System.out.println(s);
			}
			inOne.close();
			inTwo.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

}
